package org.cc.media.player;

import java.io.IOException;
import java.io.InputStream;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.UnsupportedAudioFileException;

public class HeadlessPlayer {
	
	private static final String url = "http://108.61.73.119:14126/7.html";
	
	public static void main(String[] args) throws IOException, InterruptedException, UnsupportedAudioFileException, LineUnavailableException  {
		
		ShoutcastPlaylistDigester digester = new ShoutcastPlaylistDigester();
		
		digester.getStreamFromId("hi");
		
		//InputStream inStream = digester.getStreamFromUrl(url);
		
		InputStream inStream = digester.getStreamFromId(url);
		
		ExecutorService threadExecutor = Executors.newFixedThreadPool(2);
		
		ShoutcastMetadataPoller poller = new ShoutcastMetadataPoller(url);
		threadExecutor.submit(poller);
		
		ShoutcastStreamPlayer player = new ShoutcastStreamPlayer(inStream);
		threadExecutor.submit(player);
	}
}

